﻿<cfsilent>

	<cfset event.setArg("pageTitle", "数据中心自动同步") />

	<cfset targetArgs = structNew() />

</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('groupUser')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">管理团队</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 link"></i>同步中心数据库人事数据
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	
	<ul class="dataSync">
		<li>
			<div class="clearfix">
				<form id="formSync" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('dataCenterSync')#</cfoutput>">
					<div class="label">
						<span class="req">*</span><b>数据校验原则</b>
						<input class="typeRadio" name="SynOpt" type="radio" value="new" checked="checked" /> 仅追加数据
						<input class="typeRadio" name="SynOpt" type="radio" value="update" /> 同步更新现有数据
					</div>
					<hr/>
					<div class="lable">
						<input id="syncTrigger" class="button" type="button" value="同步数据" />
					</div>
				</form>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					function syncTeacherAccount() {
												
						$.get(
								"<cfoutput>#buildURL('apiSyncTeacherAccount')#</cfoutput>",
								{
									'seed': (new Date()).getTime()
								},
								function(data){

									$("#progress").removeClass("hidden_elem");
									
									/* fresh progress bar */
									$("#pbSync").progressBar(100, {
																	boxImage : '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbar.gif',
																	barImage : {
																				0:  '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_red.gif',
																				30: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_orange.gif',
																				80: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_green.gif'
																	}
																});

									/* fresh message */
									$("#output").text("正在刷新教师帐号");
									
									$("#syncLogTeacherAccount").html(data);
									
								});
					}
					
					function syncTeacher() {
						
						var SynOpt = $(":input[name='SynOpt'][checked]").val();
						
						$.get(
								"<cfoutput>#buildURL('apiSyncTeacher')#</cfoutput>",
								{
									'SynOpt': SynOpt,
									'seed': (new Date()).getTime()
								},
								function(data){

									$("#progress").removeClass("hidden_elem");
									
									/* fresh progress bar */
									$("#pbSync").progressBar(80, {
																	boxImage : '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbar.gif',
																	barImage : {
																				0:  '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_red.gif',
																				30: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_orange.gif',
																				80: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_green.gif'
																	}
																});

									/* fresh message */
									$("#output").text("正在同步教师数据");
									
									$("#syncLogTeacher").html(data);
									
									syncTeacherAccount();
									
								});
					}
					
					function syncDepartment() {
						
						var SynOpt = $(":input[name='SynOpt'][checked]").val();
						
						$.get(
								"<cfoutput>#buildURL('apiSyncDepartment')#</cfoutput>",
								{
									'SynOpt': SynOpt,
									'seed': (new Date()).getTime()
								},
								function(data){

									$("#progress").removeClass("hidden_elem");
									
									/* fresh progress bar */
									$("#pbSync").progressBar(30, {
																	boxImage : '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbar.gif',
																	barImage : {
																				0:  '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_red.gif',
																				30: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_orange.gif',
																				80: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_green.gif'
																	}
																});

									/* fresh message */
									$("#output").text("正在同步单位数据");
									
									$("#syncLogDepart").html(data);
									
									
									syncTeacher();
									
									
								});
					}

					$(document).ready(function() {
						
						$("#syncTrigger").click(function(){

							$("#progress").removeClass("hidden_elem");
							
							$("#pbSync").progressBar({
													boxImage : '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbar.gif',
													barImage : {
																0:  '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_red.gif',
																30: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_orange.gif',
																80: '<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/widget/progressbar/images/progressbg_green.gif'
													}
												});
							
							$("#syncLogDepart").html('');
							$("#syncLogTeacher").html('');
							$("#syncLogTeacherAccount").html('');
							
							syncDepartment();

						});
						
					});

					// -->
					//]]>
				</script>
			</div>
		</li>
	</ul>
	
	
	<ul id="progress" class="hidden_elem">
		<li>
			<div class="clearfix">
				<div class="UIProgressbar">
					<span class="progressBar" id="pbSync">0%</span>
					<p id="output">处理队列初始化</p>
				</div>
			</div>
			
			<div id="syncLogDepart" class="clearfix UIOutputBox"><!--.--></div>
			<div id="syncLogTeacher" class="clearfix UIOutputBox"><!--.--></div>
			<div id="syncLogTeacherAccount" class="clearfix UIOutputBox"><!--.--></div>
			
		</li>
	</ul>
</div>